package com.young.design.pattern.future;

import java.util.concurrent.TimeUnit;

/**
 * @ClassName : Client
 * @Author : hyy
 * @Date: 2020-03-14
 */
public class Client {
    public static void main(String[] args) throws InterruptedException {
        FutureData futureData = new FutureData();

        new Thread(()->{
            System.out.println("开始异步处理业务");
            try {

                RealData realData = new RealData();
                realData.handle();
                futureData.setRealData(realData);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();

        System.out.println("开始处理主业务");
        TimeUnit.SECONDS.sleep(5);


        String result = futureData.getResult();
        System.out.println(result);

    }
}
